package learningtests;

import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.SortedMap;
import java.util.TreeMap;

import org.junit.*;
import static org.junit.Assert.*;

public class TreeMapLearning {

    @Test
    public void testUsingTreeMap() {

        TreeMap<String, String> map = new TreeMap<String, String>();

        String[] testStrings = { "zoopery", "zoopia", "zoom", "zoom box", "zoom button", "zoom in", "zoom lens",
                "zoom out", "zoom picture", "zoom-in", "zoomar", "zooming", "zoomorphic", "zoomorphism", "zoomosix",
                "zoonomorphic", "zoonomorphism", "zoonomy", "zoonosis", "zoonosology", "zoopathology", "zoophaga",
                "zoophagan", "zoophagous", "zoophilous", "zoophobia", "zoophorus", "zoophysiology", "zoophyte", };

        for (String string : testStrings) {
            map.put(string, string);
        }

        // Set<Map.Entry<String, String>> ordered = map.entrySet();

        SortedMap<String, String> tailMap = map.tailMap("zoopath", true);

        Set<Map.Entry<String, String>> entrySet = tailMap.entrySet();

        List<String> similarWords = new ArrayList<String>(10);

        int count = 0;

        for (Map.Entry<String, String> entry : entrySet) {
            similarWords.add(entry.getKey());
            count++;
            if (count == 10) {
                break;
            }
        }

        System.out.println(similarWords);

    }
}
